var document_title = document.title;

$(document).ready(function () {
    console.log("版权所有，盗我代码还不留原始版权的人是小狗！→_→")
    // debugger
    // fix form bug...
    $("form[action='']").attr('action', window.location.href);

    //响应式导航条效果
    $('.aw-top-nav .navbar-toggle').click(function () {
        if ($(this).parents('.aw-top-nav').find('.navbar-collapse').hasClass('active')) {
            $(this).parents('.aw-top-nav').find('.navbar-collapse').removeClass('active');
        } else {
            $(this).parents('.aw-top-nav').find('.navbar-collapse').addClass('active');
        }
    });

    //检测通知
    if (typeof (G_NOTIFICATION_INTERVAL) != 'undefined') {
        AWS.Message.check_notifications();
        AWS.G.notification_timer = setInterval('AWS.Message.check_notifications()', G_NOTIFICATION_INTERVAL);
    }

    //文章列表样式调整
    if ($('.aw-common-list').length) {
        $.each($('.aw-common-list .aw-item.article'), function (i, e) {
            if ($(this).find('.all-content img').length >= 1) {
                $(this).find('.markitup-box').prepend($(this).find('.all-content img').eq(0).addClass('pull-left inline-img'))
            }
        });
    }

    if (window.location.hash.indexOf('#!') != -1) {
        if ($('a[name=' + window.location.hash.replace('#!', '') + ']').length) {
            $.scrollTo($('a[name=' + window.location.hash.replace('#!', '') + ']').offset()['top'] - 20, 600, {queue: true});
        }
    }
    /*icon tooltips提示*/
    $(document).on('mouseover', '.follow, .voter, .aw-icon-thank-tips, .invite-list-user', function () {
        $(this).tooltip('show');
    });

});

$(window).on('hashchange', function () {
    if (window.location.hash.indexOf('#!') != -1) {
        if ($('a[name=' + window.location.hash.replace('#!', '') + ']').length) {
            $.scrollTo($('a[name=' + window.location.hash.replace('#!', '') + ']').offset()['top'] - 20, 600, {queue: true});
        }
    }
});

